<style>
    lable {width:10px;}
</style>
<div class="section">
        <?php
        $this->widget('AdminBankMenu', array(
            'bank_id' => $model->id,
            'bank_title' => $model->title,
        ));
        ?>
		<div class="box">
			<div class="title">
				<h2><?php if($deposit->deposit_type_id) print Yii::t('app','Добавление вклада'); else print Yii::t('app','Редактировать вклад'); ?></h2>
				<span class="hide"></span>
			</div>
<div class="content forms">
             <?php $form=$this->beginWidget('CActiveForm', array(
                            'id'=>'deposit-form',
                            'enableAjaxValidation'=>false,
                            'action'=>"/admin.php/banks/deposit/id/$deposit->id/bank_id/$model->id",
             
                    )); ?>
    <?php print $form->errorSummary($deposit); ?>
    <table>
        <tr>
            <td>
                        <div class="line1" style="clear:both;"><!-----FIRST ROW-------->
                                <div style="float:left;">
                                    <div class="name_param">Наименование вклада:</div>
                                    <?php echo $form->textField($deposit,'title',array('class'=>'medium')); ?>
                                    <?php echo $form->error($deposit,'title'); ?>
                                </div> 
                                <div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <div style="float:left;">
                                    <div class="name_param">Тип вклада:</div>
                                    <div class="select_adjustment">
                                            <?php echo $form->dropDownList($deposit, 'deposit_type_id', CHtml::listData(DepositTypes::model()->findAll(), 'id', 'title')); ?>
                                            <?php echo $form->error($deposit,'deposit_type_id'); ?>
                                             <script language="javascript">  
                                                    $(document).ready(function(e) {
                                                        if($("#type_vklad").length)
                                                            $("#type_vklad").msDropDown();
                                                    });  
                                            </script>
                                    </div>
                                </div>
                                <div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <div style="float:left;">
                                    <div class="name_param">Регион:</div>
                                    <div class="select_adjustment">   
                                    <?php echo $form->dropDownList($deposit, 'region_id', $regions, array('empty'=>Yii::t('app','Все регионы'),'id'=>'select_adjustment','class'=>'jcalendar-select-val')); ?>
                                         <?php echo $form->error($deposit,'region_id'); ?>
                                         <script language="javascript">  
                                                $(document).ready(function(e) {  
                                                    if($("#select_adjustment").length)
                                                        $("#select_adjustment").msDropDown();
                                                });  
                                        </script>
                                    </div>
                                </div>  
                        </div>
             </td>
         </tr>
         <tr>
            <td>
            <div id="depoBuf">
                <?php foreach ($modelRates as $item):?>
                    <?=$this->renderPartial('_deposit_rates_list', array(
                        'model'=>$item,  
                    )); ?>
                <?php endforeach?>
<script>
    function del_deposit_rate(rate_id){
        $.ajax({
            url: "/admin.php/banks/depositsrateajaxdel",
            type: "GET",
            data: ({ id : rate_id }),
            success: function(data) {
                $('#itemRate'+rate_id).remove();
            },
            error: function(e) {
                alert('Error occured');
            }
        });
    }
</script>
            </div>     
             <?=$this->renderPartial('_deposit_rates_form', array(   
                        'form'=>$form,
                        'ins_id'=>$deposit->id,
                    )); ?>
            </td>
         </tr>
         <tr>
             <td>
                <div class="item_three_column"><?php //<!---------FOURTH ROW----------> ?>
                    <div class="item" style="width:190px;">
                            <div class="name_param">Возможность пополнения:</div>
                                    <?php echo $form->radioButtonList($deposit,'is_increased',array('0'=>'Нет','1'=>'Да'),array('template'=>'<div style="position:relative;width:30px;height:17px;"><div style="position:absolute;left:15px;top:-5px;">{label}</div><div style="width:10px;">{input}</div></div>','separator'=>'')); ?>
                            <br/>
                            <div id="depoMinBuf">
                                <?php foreach ($modelRatesMin as $item):?>
                                    <?=$this->renderPartial('_deposit_rates_min_list', array(
                                        'model'=>$item,  
                                    )); ?>
                                <?php endforeach?>
                            </div> 
                            <?=$this->renderPartial('_deposit_rates_min_form', array( 
                                'form'=>$form,
                                'ins_id'=>$deposit->id,
                            )); ?>
                            <br><br>
                            <table cellpadding="0" cellspacing="0" style="width:500px">
                                    <tr>
                                            <td><div class="name_param sz11">Макс. сумма пополнения:</div></td>
                                            <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                            <td width="300" style="padding-right:5px; padding-top:6px;">
                                                    <div class="name_param sz11">Первоначальный взнос <a href="#" onclick="return false" class="green">Х</a></div></td>
                                            <td width="300">
                                                    <?php echo $form->textField($deposit,'initial_deposit',array('class'=>'small', 'style'=>'')); ?>
                                                    <?php echo $form->error($deposit,'initial_deposit'); ?>
                                            </td>
                                    </tr>
                            </table>
                    </div>	
                    <div class="item" style="width:255px;">
                            <div class="name_param">Возможность снятия:</div>
                            <div class="variat_select">
                                    <?php echo $form->radioButtonList($deposit,'is_allow_withdraw',array('0'=>'Нет','1'=>'Да'),array('template'=>'<div style="position:relative;width:30px;height:17px;"><div style="position:absolute;left:15px;top:-5px;">{label}</div><div style="width:10px;">{input}</div></div>','separator'=>'')); ?>
                            </div>
                            
                            <div class="name_param">Условия снятия:</div>
                                <?php echo $form->textArea($deposit,'terms_removing',array('class'=>'small','style'=>'')); ?>
                                <?php echo $form->error($deposit,'terms_removing'); ?>
                            <br/><br/>
                            <div class="name_param">Досрочное расторжение:</div>
                            
                            <div id="depoAnnulmentTermsBuf">
                                <?php foreach ($DepositRateAnnulmentTerms as $item):?>
                                    <?=$this->renderPartial('_deposit_rates_annulment_terms_list', array(
                                        'model'=>$item,  
                                    )); ?>
                                <?php endforeach?>
                            </div>
                            <?=$this->renderPartial('_deposit_rates_annulment_terms_form', array( 
                                'form'=>$form,
                                'ins_id'=>$deposit->id,
                            )); ?>
                            
                    </div>
                    <div class="item" style="margin-right:0; width:190px;">
                            <div class="name_param">Капитализация процентов:</div>
                            <div class="variat_select">
                                    <?php echo $form->radioButtonList($deposit,'is_percent_capitalization',array('0'=>'Нет','1'=>'Да'),array('template'=>'<div style="position:relative;width:30px;height:17px;"><div style="position:absolute;left:15px;top:-5px;">{label}</div><div style="width:10px;">{input}</div></div>','separator'=>'')); ?>
                            </div>
                            <br>
                            <div class="name_param sz11">Период капитализации:</div>
                            <div class="select_adjustment valuta">
                                    <?php echo $form->dropDownList($deposit, 'cap_period_id', CHtml::listData(DepositCapPeriod::model()->findAll(), 'id', 'title'), array('id' => 'capital_pr',  'class' => 'jcalendar-select-val')); ?>
                                    <?php echo $form->error($deposit, 'cap_period_id'); ?> 
                                     <script language="javascript">  
                                            $(document).ready(function(e) {  
                                                    $("#capital_pr").msDropDown();
                                            });  
                                    </script>
                            </div>
                            <br>
                            <div class="name_param">Прогрессирующая ставка:</div>
                            <div class="variat_select">
                                    <?php echo $form->radioButtonList($deposit,'is_percent_increase',array('0'=>'Нет','1'=>'Да'),array('template'=>'<div style="position:relative;width:30px;height:17px;"><div style="position:absolute;left:15px;top:-5px;">{label}</div><div style="width:10px;">{input}</div></div>','separator'=>'')); ?>
                            </div>
                    </div>
            </div>
             </td>
         </tr>
         <tr>
             <td><?php //<!-------FIFTH ROW---------> ?>
                 <div class="item">
                        <div class="name_param">Порядок выплаты процентов:</div>
                        <?php echo $form->textArea($deposit,'percent_paid_order',array('class'=>'medium')); ?>
                        <?php echo $form->error($deposit,'percent_paid_order'); ?>
                </div>
                <div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                <div class="item item_sec">
                        <div class="name_param">Особенности вклада:</div>
                        <?php echo $form->textArea($deposit,'features',array('class'=>'medium')); ?>
                        <?php echo $form->error($deposit,'features'); ?>
                </div>
             </td>
        </tr>
    </table>

        <div class="line button">
            <button type="submit" class="green medium"><span><?=(($deposit->deposit_type_id)?'Сохранить':'Добавить')?></span></button>
            <button type="submit" onclick="window.location.replace('<?=$this->createUrl("/banks/deposits/id/$model->id")?>');return false; " class="blue medium"><span>Отмена</span></button>

            <?php if ($deposit->id):?>
                    <?= CHtml::link(Yii::t('app', 'Удалить'), $this->createUrl("banks/depositDel",array('id' => $deposit->id,'bank_id'=>$model->id)), array('class' => 'red medium',
                    'confirm' => 'Вы уверены что хотите удалить этот элемент?')) ?>
            <?php endif?>
        </div>

    </div>

    <?$this->endWidget(); ?>

			</div>
		</div>
                   
        